<?php
namespace BP\Sys;
require_once("BP/Difference/Handler/CommonUtils.php");
abstract class FormEventBase {
	public $HisEn;	// Entity
	protected $_SysPara;	// Row
	private function __init() { // default class members
		$this->HisEn = NULL;
		$this->_SysPara = NULL;
	}
	abstract function getFormMark (); 
	public function getSysPara () 
	{
		if (($this->_SysPara == NULL))
		{
			$this->_SysPara = new Row();
		}
		return $this->_SysPara;
	}
	public function setSysPara ($value) // [Row value]
	{
		$this->_SysPara = $value;
	}
	public function getFK_Mapdata () 
	{
		return $this->GetValStr("FK_MapData");
	}
	public function getOID () 
	{
		return $this->GetValInt("OID");
	}
	public function GetValDateTime ($key) // [String key]
	{
		try 
		{
			$str = $this->getSysPara()->GetValByKey($key);
			return $DataType->ParseSysDateTime2DateTime($str);
		}
		catch (\RuntimeException $ex)
		{
			throw new \RuntimeException(((("@表单事件实体在获取参数期间出现错误，请确认字�?(" . $key) . ")是否拼写正确,�?术信�?:") . $ex->getMessage()));
		}
	}
	public function GetValStr ($key) // [String key]
	{
		try 
		{
			return $this->getSysPara()->GetValByKey($key);
		}
		catch (\RuntimeException $ex)
		{
			throw new \RuntimeException(((("@表单事件实体在获取参数期间出现错误，请确认字�?(" . $key) . ")是否拼写正确,�?术信�?:") . $ex->getMessage()));
		}
	}
	public function GetValInt64 ($key) // [String key]
	{
		return $Long->parseLong($this->GetValStr($key));
	}
	public function GetValInt ($key) // [String key]
	{
		return $Integer->parseInt($this->GetValStr($key));
	}
	public function GetValBoolen ($key) // [String key]
	{
		if (($Integer->parseInt($this->GetValStr($key)) == 0))
		{
			return  FALSE ;
		}
		return  TRUE ;
	}
	public function GetValDecimal ($key) // [String key]
	{
		return new BigDecimal($this->GetValStr($key));
	}
	public static function constructor__ () 
	{
		$me = new self();
		$me->__init();
		return $me;
	}
	public function FrmLoadAfter () 
	{
		return NULL;
	}
	public function FrmLoadBefore () 
	{
		return NULL;
	}
	public function BeforeFormDel () 
	{
		return NULL;
	}
	public function AfterFormDel () 
	{
		return NULL;
	}
	public function SaveAfter () 
	{
		return NULL;
	}
	public function SaveBefore () 
	{
		return NULL;
	}
	public function AthUploadeBefore () 
	{
		return NULL;
	}
	public function AthUploadeAfter () 
	{
		return NULL;
	}
	public function DtlRowSaveBefore () 
	{
		return NULL;
	}
	public function DtlRowSaveAfter () 
	{
		return NULL;
	}
	public function CreateOID () 
	{
		return NULL;
	}
	public function DoIt ($eventType, $en, $atPara) // [String eventType, Entity en, String atPara]
	{
		$this->HisEn = $en;
		$r = $en->getRow();
		try 
		{
			$r->put("FK_MapData", $en->getClassID());
		}
		catch (\Exception $e)
		{
			$r->put("FK_MapData", $en->getClassID());
		}
		if (($atPara . NULL))
		{
			$ap = new AtPara($atPara);
			foreach ($ap->getHisHT()->keySet() as $s) 			{
				try 
				{
					$r->put($s, $ap->GetValStrByKey($s));
				}
				catch (\Exception $e2)
				{
					$r->put($s, $ap->GetValStrByKey($s));
				}
			}
		}
		if ((SystemConfig::getIsBSsystem() ==  TRUE ))
		{
			foreach ($CommonUtils->getRequest()->getParameterMap()->keySet() as $keyObject) 			{
				if (($keyObject == NULL))
					continue;
				$key = $keyObject;
				$val = $CommonUtils->getRequest()->getParameter($key);
				try 
				{
					$r->put($key, $val);
				}
				catch (\Exception $e3)
				{
					$r->put($key, $val);
				}
			}
		}
		$this->setSysPara($r);
		switch ($eventType) {
			case FrmEventList::$CreateOID:
				return $this->CreateOID();
			case FrmEventList::$FrmLoadAfter:
				return $this->FrmLoadAfter();
			case FrmEventList::$FrmLoadBefore:
				return $this->FrmLoadBefore();
			case FrmEventList::$SaveAfter:
				return $this->SaveAfter();
			case FrmEventList::$SaveBefore:
				return $this->SaveBefore();
			case FrmEventList::$AthUploadeBefore:
				return $this->AthUploadeBefore();
			case FrmEventList::$AthUploadeAfter:
				return $this->AthUploadeAfter();
			case FrmEventList::$DtlRowSaveBefore:
				return $this->DtlRowSaveBefore();
			case FrmEventList::$DtlRowSaveAfter:
				return $this->DtlRowSaveAfter();
			default:
				throw new \RuntimeException(("@没有判断的表单事件类�?:" . $eventType));
		}
	}
}
?>
